<?php

/**
 * Формирует URL с указанными параметрами.
 *
 * @access  public
 * @param   array   $params
 * @param   Smarty  $smarty
 */
function smarty_function_list_url($params, &$smarty) {
    require_once $smarty->_get_plugin_filepath('function', 'url');

    if (!isset($params['action'])) {
        trigger_error('mandatory param is empty: action', E_USER_ERROR);
    }

    if (!isset($params['item'])) {
        trigger_error('mandatory param is empty: item', E_USER_ERROR);
    }

    if (!isset($params['key'])) {
        trigger_error('mandatory param is empty: key', E_USER_ERROR);
    }

    return smarty_function_url(array(
        'query' => array_merge($params['action'], array_extract($params['item'], $params['key'])),
    ), $smarty);
}
